import request from "@/utils/request";
import qs from "querystring";


// 获取角色列表
function rolesList() {
    return request({
         url:'/roles',
         method:'get',
    })
}


// 添加
function addroles(obj) {
    return request({
         url:'/roles',
         method:'post',
         data:obj
    })
}

// 编辑
function editroles(id,obj) {
    return request({
         url:`roles/${id}`,
         method:'put',
         data:obj
    })
}



// 删除
function delroles(id) {
    return request({
         url:`roles/${id}`,
         method:'delete',
    })
}

// 删除角色指定权限
function delrights(roleId,rightId) {
    return request({
         url:`roles/${roleId}/rights/${rightId}`,
         method:'delete',
    })
}

function rightList() {
    return request({
         url:'rights/tree',
         method:'get',
    })
}

function sureright(roleId,rids) {
    return request({
        url:`roles/${roleId}/rights`,
        method:'post',
        data:rids
   })
}


export {rolesList,addroles,delroles,editroles,delrights,rightList,sureright}